import allure
from selenium.webdriver.common.by import By
from base.base_driver import BaseDriver
from pages.add_person_page import AddPersonPage
from pages.contact_page import ContactPage


class MainPage(BaseDriver):
    _CONTACT_BTN = By.ID, "menu_contacts"
    _ADD_PERSON_BTN = By.XPATH, "//span[text()='添加成员']"

    def goto_contact_page(self):
        # logger.info('点击通讯录')
        with allure.step("点击通讯录"):
            self.find_and_click(*self._CONTACT_BTN)
        # 进入通讯录页面
        with allure.step("进入通讯录页面"):
            return ContactPage(self.driver)

    def goto_add_person_page(self):
        # logger.info('点击添加成员')
        with allure.step("点击添加成员"):
            self.find_and_click(*self._ADD_PERSON_BTN)
        # 进入添加成员页面
        with allure.step("进入添加成员页面"):
            return AddPersonPage(self.driver)
